import { transactionTypeData, paymentType } from 'utils/seletLocalData'

/**
 *  @desc 给对象/数组增加相应属性
 *  @param 预增加属性的原始数据、type类型(from、to)、数据源
 */
const propData = ['foreignExchangeRate', 'fundsCode', 'fundsComment']
const addparamsToClient = (originData, type, fileds) => {
  if (!Array.isArray(originData)) {
  // 给对象加上相应的属性值，根据propdata比较拿取filedsValue的相应属性值 注意from和to的对应
    propData.forEach((item) => {
      if (Array.isArray(fileds[item])) {
        originData[item] = fileds[item].key
      } else {
        originData[item] = fileds[item]
      }
    })
    originData.foreignAmount = fileds[`${type}Amount`]
    originData.foreignCurrencyCode = fileds[`${type}CurrencyCode`]
  } else {
    originData.forEach((item) => {
      addparamsToClient(item, type, fileds)
    })
  }
  return originData
}
/**
 *  @desc 生成menu
 *
 */
const createMenu = (type, data) => {
  let resArr = []
  for (let i = 0; i < data.length; i++) {
    let s = type & (1 << i)
    if (s !== 0) {
      resArr.push(data[i])
    }
  }
  return resArr
}

export {
  addparamsToClient,
  createMenu,
}
